package com.admin.controller;


import com.admin.common.lang.Result;
import com.admin.entity.User;
import com.admin.service.UserService;
import com.baomidou.mybatisplus.extension.api.R;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

/**
 * <p>
 * 前端控制器
 * </p>
 *
 * @author 作者：admin
 * @since 2020-08-26
 */
@RestController
@RequestMapping("/user")
@Api(tags = "用户相关接口")
public class UserController {

    @Autowired
    UserService userService;

    @GetMapping("/index")
    @ApiOperation("创建用户")
    public Result index() {
        User user = userService.getById(2L);
        return Result.succ(200, "操作成功", user);
    }

    @PostMapping("/save")
    @ApiOperation("保存用户")
    public Result save(@Validated @RequestBody User user){
        return Result.succ(user);

    }


}
